﻿using PHMEE.Admin;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PHMEE.MqttClient.MqttBusinessCommand
{
    /// <summary>
    /// 请求策略参数业务处理
    /// </summary>
    public class SysParaCommand : BaseCommand
    {
        private readonly ISysParaAppService _sysParaAppService;

        public SysParaCommand(ISysParaAppService sysParaAppService)
        {
            _sysParaAppService = sysParaAppService;
        }
        public override async Task ExecuteAsync(string requestInfo)
        {
            Console.WriteLine($"=====我是处理【SysPara业务:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff")}】====");

            //return Task.CompletedTask;
            {
                //await Task.Run(() =>
                //{
                //    isReplay = true;
                //    var res = new SysParaDto();
                //    DateTime lastTimeObj = DateTime.Parse("2024-05-13T10:54:22");
                //    res.SysTime = DateTime.Now;
                //    res.ParaTime = lastTimeObj;
                //    res.IndexPeriod = 20;
                //    res.TechPeriod = 20;
                //    res.WavePeriod = 60;
                //    res.LongWavePeriod = 86400;
                //    res.CollectType = 1;
                //    res.OutType485 = 0;
                //    res.RpmPeriod = 20;
                //    res.RtuPeriod = 20;
                //    res.UserCustom = 4;
                //    res.CustomParams = null;
                //    res.UploadPeriod = 7200;
                //    res.AlarmCount = 3;
                //    res.UnAlarmCount = 3;
                //    res.VelLowerFrq = 10;
                //    res.VelUpperFrq = 2000;
                //    ResPonsePayload = res;
                //});
            }
            await Task.Run(async () =>
            {
                isReplay = true;
                var res = await _sysParaAppService.GetByIdUseMqttAsync(SN);
                DateTime lastTimeObj = res.ParaTime;
                res.SysTime = DateTime.Now;
                res.ParaTime = lastTimeObj;
                ResPonsePayload = res;
            });
        }
    }
}
